// 引入封装好的 post 请求
import post from '../config/post';

const USER_BASE_URL = "api/user"
// 定义各个请求的路径
const REGISTER_URL = USER_BASE_URL+'/userLogin/register';
const SEND_VERIFICATION_CODE_URL = USER_BASE_URL+'/userLogin/verCode';
const LOGIN_BY_USERNAME_URL = USER_BASE_URL+'/userLogin/login';
const LOGIN_BY_PHONE_URL = USER_BASE_URL+'/userLogin/loginByPhone';

// 注册用户
const register = (params, successCallback, failCallback) =>
    post(REGISTER_URL, params, successCallback, failCallback);

// 发送验证码
const sendVerificationCode = (params, successCallback, failCallback) =>
    post(SEND_VERIFICATION_CODE_URL, params, successCallback, failCallback);

// 用户名和密码登录
const loginByUserName = (params, successCallback, failCallback) =>
    post(LOGIN_BY_USERNAME_URL, params, successCallback, failCallback);

// 手机号和验证码登录
const loginByPhone = (params, successCallback, failCallback) =>
    post(LOGIN_BY_PHONE_URL, params, successCallback, failCallback);

// 导出所有请求函数，便于其他模块使用
export { register, sendVerificationCode, loginByUserName, loginByPhone };
